<?php
include_once("../FachadaBD.php");

//Clase Mensaje
class Mensaje{
	//Variables principales
	var $postid;
	var $author;
	var $title;
	var $foro;
	var $post;
	var $showtime;
	var $realtime;
	var $lastposter;
	var $numreplies;
	var $parentid;
	var $lastrepliedto;
	
	function Mensaje($postid,$author,$title,$foro,$post,$showtime,$realtime,$lastposter,$numreplies,$parentid,$lastrepliedto){
		$this->postid = $postid;
		$this->author = $author;
		$this->title = $title;
		$this->foro = $foro;
		$this->post = $post;
		$this->showtime = $showtime;
		$this->raeltime = $realtime;
		$this->lastposter = $lastposter;
		$this->numreplies = $numreplies;
		$this->parentid = $parentid;
		$this->lastrepliedto = $lastrepliedto;
	}
	
	function obtenerDatosMensaje($id){
		$BDf=FachadaBD::getInstance();
		$conect=$BDf->conectarse();
		$gettopic2 = $BDf->MensajesForo($id);
		$gettopic3=mysql_fetch_array($gettopic2);
		$array = Array();
		$array["author"] = $gettopic3["author"];
		$array["showtime"] = $gettopic3["showtime"];
		$array["post"] = $gettopic3["post"];		
		$BDf->desconectar($conect);
		return $array;
	}
	
	function obtenerHijos($id){
		$BDf=FachadaBD::getInstance();
		$conect=$BDf->conectarse();
		$getreplies2=$BDf->HijosMensaje($id);
		$BDf->desconectar($conect);
		return $getreplies2;
	}
	
	function insertarMensajePost(){
		$BDf=FachadaBD::getInstance();
		$conect=$BDf->conectarse();
		$BDf->AgregarPost($this->title,$this->author,$this->foro,$this->post);
		$BDf->desconectar($conect);
	}
	
	function insertarMensajeReply($id){
		$BDf=FachadaBD::getInstance();
		$conect=$BDf->conectarse();
		$BDf->AgregarRespuesta($this->title,$this->author,$this->post,$id);
		$BDf->desconectar($conect);
	}
	
	function getNombre(){return $this->nombre;}
}
?>